<?php
/**
 * Created by XM·Tan.
 * Motto: Who shuts love out, in turn shall be shut out from love.
 * Date: 2021/4/24 21:46
 */

namespace app\admin\controller;

use app\admin\business\SiteLog as SiteLogBus;
use app\common\lib\Show;
use think\facade\View;

class SiteLog extends AdminBase {

    public $business = null;
    public function __construct() {
        $this->business = new SiteLogBus();
    }

    public function index() {
        return View::fetch();
    }

    public function getLists() {
        $data = [];
        $limit = input('param.limit', 10, 'intval');
        $username = input('param.username', '', 'trim');

        if (!empty($username)) {
            $data['username'] = $username;
        }

        $result = $this->business->getLists($data, $limit, ['create_time' => 'DESC']);
        return Show::show_lay_table(config('layui.success'), '', $result['total'], $result['data']);
    }

    // 删除一个月前的操作日志
    public function deleteLog() {
        $this->business->delete();
        return Show::success('删除日志成功！');
    }

}